package com.leapp.sk.viewdelegate.task

import android.content.Context
import android.support.v4.content.ContextCompat
import android.support.v4.widget.SwipeRefreshLayout
import android.text.TextUtils
import com.example.mvp.delegate.BaseAppDelegate
import com.example.mvp.view.RefreshListView
import com.example.mvp.view.SKTopBar
import com.leapp.sk.R
import com.leapp.sk.bean.ParentingTaskEntity
import com.leapp.sk.ui.activity.task.ParentingTaskActivity
import com.leapp.sk.ui.adapter.ParentingTaskAdapter

/**
 * 所有作业视图托管类
 * @author  chaohaipeng  on 2018/8/10.
 */
class AllParentingTaskDelegate : BaseAppDelegate(){
    override fun initWidget() {
    }

    override fun initLayoutRes(): Int {
        return R.layout.fragment_all_parenting_task
    }
    /**
     * 初始化适配器
     */
    fun initAdapter(context: Context, mlist: List<ParentingTaskEntity>, listener: SwipeRefreshLayout.OnRefreshListener){
        val lv_fapt_list = getView<RefreshListView>(R.id.lv_fapt_list)
        val srl_fapt_swipe = getView<SwipeRefreshLayout>(R.id.srl_fapt_swipe)
        val classNotifyAdapter = ParentingTaskAdapter(getActivity(), mlist)
        lv_fapt_list.adapter=classNotifyAdapter
        srl_fapt_swipe.setOnRefreshListener(listener)
        srl_fapt_swipe.setColorSchemeColors(ContextCompat.getColor(context, R.color.color_19AD19))
    }

    /**
     * 停止刷新
     */
    fun stopSwipRefresh(){
        val srl_fapt_swipe = getView<SwipeRefreshLayout>(R.id.srl_fapt_swipe)
        srl_fapt_swipe.isRefreshing=false
    }



}